<template>
  <div class="task-time-info-group">
    <el-table
      class="task-time-info-table"
      :data="groupSendLog"
      stripe
      style="width: 100%"
      height="60px"
    >
      <el-table-column
        label="任务类型"
        :filters="taskTypes"
        prop="tasktype"
        :filter-method="filterTaskTypes"
      >
        <template slot-scope="scope">
          <span v-text="tasktypeMap[scope.row.tasktype]"></span>
        </template>
      </el-table-column>
      <el-table-column label="消息类型">
        <template slot-scope="scope">
          <span v-text="restypeMap[scope.row.restype]"></span>
        </template>
      </el-table-column>
      <el-table-column prop="content" label="消息内容"></el-table-column>
      <el-table-column label="当前状态">
        <template slot-scope="scope">
          <span v-text="scope.row.state === 0 ? '发送成功':'发送中'"></span>
        </template>
      </el-table-column>
      <el-table-column prop="execute_time" label="开始时间"></el-table-column>
      <el-table-column label="结束时间">
        <template slot-scope="scope">
          <span v-text="$options.filters.transformTime2Minute(scope.row.createTime)"></span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'GroupAssistantLog',
  data() {
    return {
      tasktypeMap: {
        1: 'PC群发消息',
        2: 'PC发朋友圈',
        3: '删除好友',
        4: '删除群聊',
        5: '群发群消息',
        6: '按标签群发',
        7: '发朋友圈',
        8: '批量加好友',
      },
      restypeMap: {
        "Text": 1,
        "Picture": 2,
        "Voice": 3,
        "Video": 4,
        "Link": 6,
        "WeApp": 13,
        1: '文本',
        2: '图片',
        3: '语音',
        4: '视频',
        6: '链接',
        13: '小程序',
      },
      taskTypes: [
        { text: '群发好友', value: 1 },
        { text: '群发群', value: 5 },
        { text: '发朋友圈', value: 2 },
      ],
    }
  },
  computed: {
    ...mapGetters({
      groupSendLog: 'nedb/groupSendLog',
    }),
  },
  methods: {
    // 任务类型过滤器
    filterTaskTypes(value, row, column) {
      const property = column['property'];
      return row[property] === value;
    },
  },
  mounted() {
    this.$store.dispatch('websocket/GetTaskInfoList')
  },
}
</script>

<style lang="scss" scoped>
.task-time-info-group {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
</style>
